package com.ruoyi.web.controller.common;


import com.ruoyi.common.utils.OSSUplodFile;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@Controller
@RequestMapping("/aliyun")
public class AliyunUploadController {

	@PostMapping("/upload")
	@ApiOperation(value = "文件上传oss方式",position = 2)
	public @ResponseBody
	Map<String, Object> ossUpload(@RequestParam("file") MultipartFile file)  {
		try {
			Map<String, Object> map = OSSUplodFile.createUpload(file);
			return map ;
		}catch (Exception e){
			e.printStackTrace();
			return null;
		}
	}
	@PostMapping("/uploadByFace")
	@ApiOperation(value = "后台通过服务器间接传文件",position = 2)
	public @ResponseBody
	Map<String, Object> uploadByFace( String file)  {
		try {
			Map<String, Object> map = OSSUplodFile.uploadByFace(file);
			return map ;
		}catch (Exception e){
			e.printStackTrace();
			return null;
		}
	}
}
